<?php
//    接收表单数据
$username=$_GET["username"];
$IDnum=$_GET["IDnum"];
$phone=$_GET["phone"];
$email=$_GET["email"];

$Myid=$_POST["id"];
$Myaddress=$_POST["address"];
$Myfloor=$_POST["floor"];
$Myproportion=$_POST["proportion"];
$MyRentmoney=$_POST["Rentmoney"];
$Myarea=$_POST["area"];
$Mytype=$_POST["type"];
$Mydirection=$_POST["direction"];
$Mysurr=$_POST["surr"];
$Mydecorate=$_POST["decorate"];
$Myissuer=$_POST["issuer"];
// 连接数据库
// require("connect.php");
// 创建连接
$conn = mysql_connect("localhost:3306","root","wohenpi0918");
mysql_set_charset('utf8',$conn);
//编码，避免出现乱码
mysql_select_db("student",$conn);
//连接数据库

// 检测连接
if (!$conn) {
    die("Connection failed: " . mysql_connect_error());
}
// echo $username;
// echo $IDnum;
// echo $phone;
// echo $email;
// $sql = "INSERT INTO user(username,idnum,phone,email)
// VALUES ($username,$IDnum,$phone,$email)";
// $sql = "INSERT INTO user(username, idnum, phone,email)
// VALUES ('John', 'Doe', '234, 'com')";
 $sql = "INSERT INTO user(username, idnum, phone, email) VALUES ('$username','$IDnum','$phone','$email')";
 if (mysql_query($sql,$conn)) {
    echo "新记录插入成功";
    
echo "<script> window.location.href='RentHouse.php';</script>";

    
    
} else {
    echo "Error: " . $sql . "<br>" . mysql_error($conn);
}
$sql1 = "INSERT INTO rent(id, address,proportion,floor,rentmoney,area,type,direction,surr,decoration,issuer) VALUES ('$Myid','$Myaddress','$Myfloor','$Myproportion','$MyRentmoney','$Myarea','$Mytype','$Mydirection','$Mysurr','$Mydecorate','$Myissuer')";
 if (mysql_query($sql1,$conn)) {
    echo "新记录插入成功";
    
echo "<script> window.location.href='RentHouse.php';</script>";

    
    
} else {
    echo "Error: " . $sql . "<br>" . mysql_error($conn);
}


 
// $str="insert into user(username,idnum,phone,email)VALUES($username,$IDnum,$phone,$email)";
// mysql_query($sql,$conn)or die('添加数据出错：'.mysql_error());
// $str1="insert into rent(id,address,proportion,floor,rentmoney,area,type,direction,decoration,issuer)VALUES('$id','$address',
// '$floor','$proportion','$Rentmoney','$area','$type','$direction','$surr','$decorate','$issuer') ";
// mysql_query($str1)or die('添加数据出错：'.mysql_error());
?>